package com.bolt.common.db.converts;

import com.bolt.common.db.DbHelper;
import com.bolt.convention.exception.ServiceException;

public class JdbcTypeConvertFactory {

    private JdbcTypeConvertFactory() {

    }

    public static IJdbcTypeConvert getJdbcTypeConvert(String dbUrl) {
        IJdbcTypeConvert typeConvert = null;
        if (DbHelper.dbTypeIsMySQL(dbUrl)) {
            typeConvert = new MySqlJdbcTypeConvert();
        } else if (DbHelper.dbTypeIsOracle(dbUrl)) {
            typeConvert = new OracleJdbcTypeConvert();
        } else if (DbHelper.dbTypeIsPostgre(dbUrl)) {
            typeConvert = new PostgreSqlJdbcTypeConvert();
        } else {
            throw new ServiceException("不支持的数据库类型");
        }
        return typeConvert;

    }
}